package com.myth.process;

public class SleepTest implements Runnable{
    private int n = 10;
    @Override

    //重写的方法
    public void run() {  //线程体
        while (n > 0){
            try {
                Thread.sleep(500);
            }catch (InterruptedException e){
                e.printStackTrace();
            }
            System.out.println(Thread.currentThread().getName()+"拿到了第"+n--+"张票");

        }
    }

//    //线程调用
//    public static void main(String[] args) {
//        SleepTest s = new SleepTest();
//        new Thread(s,"小明").start();
//        new Thread(s,"小花").start();
//        new Thread(s,"黄牛").start();
//    }

//    //倒计时
//    public static void main(String[] args) throws InterruptedException {
//        System.out.println("倒计时还有10秒");
//        for (int i = 10; i > 0; i--) {
//            Thread.sleep(1000);
//            System.out.println(i);
//        }
//    }

}
